#include <stdarg.h>
#include <windows.h>
#include <stdio.h>
#include "DebugLog.h"


/* Funtions Prototyes */
void WriteLog(int nLogLevel, char *pFormat, ...);
BOOL isLogOnServer = FALSE;
int main() {
	isLogOnServer = TRUE;
	WriteLog(1, "\n=====================");
	InfoLog("HieuMT INFO LOG");
	return 0;
}

void WriteLog(int nLogLevel, char *pFormat, ...)
{
	char chMsg[1024];
	char chFile[260];
	FILE *fp;
	char *g_szConfigurationLogPath = "D:";

	va_list pArg;
	va_start(pArg, pFormat);
	vsprintf(chMsg, pFormat, pArg);
	va_end(pArg);
	
	SYSTEMTIME st;
	GetLocalTime(&st);
	sprintf(chFile, "%s\\WinCPA_%02d%02d.log", g_szConfigurationLogPath, st.wMonth, st.wDay);
	
	fp = fopen(chFile, "a+t");
	if(fp != NULL)
	{
		fseek(fp, 0, SEEK_END);
		fprintf(fp, "[%02d:%02d:%02d] %s\n", st.wHour, st.wMinute, st.wSecond, chMsg);
		fflush(fp);
		fclose(fp);
	}
}